<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script type="text/javascript" src="/static/assets/js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/assets/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="/static/assets/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/static/assets/flut_ui/css/flat-ui.css">
    <script type="text/javascript" src="/static/assets/flut_ui/scripts/flat-ui.js"></script>
    <link rel="stylesheet" href="/static/assets/layui/css/layui.css">
    <script type="text/javascript" src="/static/assets/layui/layui.js"></script>
  

</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12" style="min-height: 100px;">
            </div>
            <div class="col-md-12">
                <h1 align="center">Register ！こんにちは</h1>
            </div>
            <div class="col-md-12" style="min-height: 100px;">
            </div>
        </div>
        <div class="row">
            <div class="col-md-4">
            </div>
            <div class="col-md-4">
                <div class="login-form">
                    <div class="control-group">
                      <input type="text" class="login-field" value="" placeholder="Enter your name" id="username">
                      <label class="login-field-icon fui-man-16" for="login-name"></label>
                    </div>

                    <div class="control-group">
                      <input type="password" class="login-field" value="" placeholder="Password" id="password">
                      <label class="login-field-icon fui-lock-16" for="login-pass"></label>
                    </div>

                    <a id="register-btn" class="btn btn-primary btn-large btn-block">Register</a>
                    <a class="login-link" href="/user/login">Login </a>
                    <a class="login-link" href="#">Lost your password?</a>
                  </div>
               
            </div>
            <div class="col-md-4">
            </div>
        </div>
      </div>

          
    </div>
    <script type="text/javascript">
        $(document).keypress(function (e) {
            // 回车键事件  
            if (e.which == 13) {
                $("#login-btn").click();
            }
        });
        $(document).ready(function() {  
            
            $("#register-btn").click(function(){
                var username = $("#username").val();
                var password = $("#password").val();
                $.ajax({
                    url: "/user/add_user",
                    type: "POST",
                    dataType: "json",
                    data:{"username":username,"password":password},
                    success: function (result){
                        if(result['datas']['code']=="1"){
                            layui.use('layer', function(){
                                var layer = layui.layer;
                                layer.msg(result['msg']);
                                location.href="/user/login";
                            });
                        }else{
                            layui.use('layer', function(){
                                var layer = layui.layer;
                                layer.msg(result['msg']);
                            });
                        }
                    }
                });
            })

            

            
        });
    </script>
</body>
</html>

